#=========================================
#     FileName: server.py
#         Desc:
#       Author: ez~
#        Email: 2511384642@qq.com
#     HomePage: 
#      Version: 0.0.1
#   LastChange: 2021-08-04 16:02:14
#      Descrip:
#
#      使用FastAPI搭建简易HTTP服务器，
#      模拟物管平台，用于接收上报的数据。
#=========================================
import uvicorn
from typing import Optional
from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()

class Iot(BaseModel):
    """定义简易物模型"""
    
    temu: int = 0
    humi: int = 0


@app.get("/v1/device/data/get")
def test_data(a, b):
    print(a, b)
    return "succeed"

@app.post("/v1/device/data/push")
def recv_data(data: Iot):
    msg = data.dict()
    print(msg)


if __name__ == '__main__':
    uvicorn.run(app=app, host='127.0.0.1', port=8000)

